<?php
//require_once dirname(dirname(__DIR__))."/common.php";
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\model\Topic;
require_once dirname(__DIR__)."/login_filter.php";

$video_uuid=$_REQUEST['video_uuid'];
$id=$_REQUEST['id'];
if(empty($video_uuid) || empty($id)){
    Response::output(-1,"参数错误");
}
//实例化数据库
$db = SysResource::getDB(false);
$Topic = new Topic($db);
//根据话题id，查询话题分类
$video_detail=$Topic->video_detail($video_uuid,$id);

//再去根据用户自己的ID去查询用户点赞和关注了哪些视频
$uuid=$Auth['uuid'];
//$uuid=2;
//查询已点赞视频
$zan=$Topic->zan($uuid);
//查询已关注视频
$guanzu=$Topic->guanzu($uuid);
$zans=[];
$zan_id=[];
$guanzus=[];

if(!empty($video_detail)){
    foreach($zan as $k=>$v){
        $zans[]=$v['video_uuid'];
        $zan_id[]=$v['other_id'];
    }
    foreach($guanzu as $kk=>$vv){
        $guanzus[]=$vv['other_uuid'];
    }

    if(in_array($video_detail['video_uuid'],$zans) && in_array($video_detail['id'],$zan_id)){
        $video_detail['is_zan']=2;
    }else{
        $video_detail['is_zan']=1;
    }
    if(in_array($video_detail['uuid'],$guanzus)){
        $video_detail['is_follow']=2;
    }else{
        $video_detail['is_follow']=1;
    }
    if($video_detail['uuid']==$uuid){
        $video_detail['is_dub']=3;
    }
    if($video_detail['uuid']==$uuid){
        $video_detail['is_user']=1;
    }else{
        $video_detail['is_user']=0;
    }
    if(empty($video_detail['share_pic'])){
        $video_detail['share_pic']="";
    }
    if(empty($video_detail['video_desc'])){
        $video_detail['video_desc']="";
    }
    $video_detail['count_material_love_10']=round($video_detail['count_material_love']*1.7);
    $video_detail['count_material_share_10']=round($video_detail['count_material_share']*1.7);

    Response::output(0,"查询成功",$video_detail);
}else{
    Response::output(0,"查询成功",[]);
}

